<?php

/**
 * This is the model class for table "__widget_layout".
 *
 * The followings are the available columns in table '_widget_layout':
 * @property integer $id
 * @property string $name
 * @property string $description
 * @property string $images
 * @property string $path
 * @property string $author
 * @property string $version
 * @property boolean $status
 * @property string $creation_datetime
 * @property string $last_update
 * @property integer $widget_id
 */
class CmsWidgetLayoutBase extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return CmsWidgetLayout the static model class
	 */
	public static function model($className='CmsWidgetLayout')
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return SITE_TABLE_PREFIX.'widget_layout';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('name, description, path, widget_id', 'required'),
			array('widget_id', 'numerical', 'integerOnly'=>true),
			array('name', 'length', 'max'=>255),
			array('path, author', 'length', 'max'=>512),
			array('version', 'length', 'max'=>128),
			array('images, status, creation_datetime, last_update', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, name, description, images, path, author, version, status, creation_datetime, last_update, widget_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'name' => 'Name',
			'description' => 'Description',
			'images' => 'Images',
			'path' => 'Path',
			'author' => 'Author',
			'version' => 'Version',
			'status' => 'Status',
			'creation_datetime' => 'Creation Datetime',
			'last_update' => 'Last Update',
			'widget_id' => 'Widget',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('description',$this->description,true);
		$criteria->compare('images',$this->images,true);
		$criteria->compare('path',$this->path,true);
		$criteria->compare('author',$this->author,true);
		$criteria->compare('version',$this->version,true);
		$criteria->compare('status',$this->status);
		$criteria->compare('creation_datetime',$this->creation_datetime,true);
		$criteria->compare('last_update',$this->last_update,true);
		$criteria->compare('widget_id',$this->widget_id);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}